<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>朴与素连锁店管理信息系统</title>
<%@ include file="../../common/Style.jsp"%>

<script>
var dataGrid ;
	
	$(document).ready(function(){
		parent.$.messager.progress('close'); 
		
		$('#barcode').textbox('textbox').keydown (function(e){
		    if (event.keyCode == 13){    

		    	searchHqInventotyStock();
		 		event.returnValue=false;
		    }
		});

		var params = $.serializeObject($('#inventorySearchForm'));
		
		dataGrid = $('#dataGrid').datagrid({
			url : 'headqInventoryFlowJSONAction!selectInventoryTracking',
			queryParams: params,
			fit : true,
			border : false,
			sortName : 'orderDate',
			sortOrder : 'desc',
			checkOnSelect : false,
			selectOnCheck : false,			
			showFooter:true,
			singleSelect:true,
			rownumbers:true,
			nowrap : false,
			columns : [ [ {
				field : 'barcode',
				title : '条码',
				width : 100,
				align: 'center',
			}, {
				field : 'year',
				title : '年份',
				width : 60,
				align: 'center',
			},{
				field : 'brand',
				title : '品牌',
				width : 120,
				align: 'center',
			},{
				field : 'category',
				title : '货品类别',
				width : 120,
				align: 'center',
			},{
				field : 'productCode',
				title : '颜色货号',
				width : 100,
				align: 'center',
			},{
				field : 'quantity',
				title : '数量',
				width : 50,
				align : 'center',
					
			},{
				field : 'discount',
				title : '折扣',
				width : 50,
				align : 'center',
				formatter: function (value, row, index){
					return row.discount.toFixed(2);
				}					
			},{
				field : 'descp',
				title : '描述',
				width : 120,
				align :'center',
					
			},{
				field : 'orderId',
				title : '单据号',
				width : 50,
				align : 'center'
			}, {
				field : 'clientName',
				title : '单据对象',
				width : 120,
				align : 'center'
			},{
				field : 'store',
				title : '仓库名称',
				width : 80,
				align:'center',	
			},{
				field : 'date',
				title : '发生日期',
				width : 120,
				sortable:true,
				order:'desc'
			},{
				field : 'actionCode',
				title : '编码',
				width : 50,
				align :'center',
					
			}, {					
				field : 'action',
				title : '查看/修改',
				width : 70,
				formatter : function(value, row, index) {
					var str = '';
					if (row.details){
						var url = "<%=request.getContextPath()%>/action/inventoryOrder!loadOrder?formBean.order.order_ID=" + row.orderId;
						str += $.formatString('<a href="#" onclick="addTab6(\'{0}\',\'{1}\');"><img border="0" src="{2}" title="修改"/></a>', url, '单据 ' + row.orderId,'<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/text_1.png');
					}
					
					return str;
				}
			}
			]],
			toolbar : '#toolbar'
		});
	});

	
	function searchHqInventotyStock(){	
		var barcode = $('#barcodeInfo').textbox('getValue');
		if(barcode == null || barcode == ""){
			 $.messager.alert('提示','条码为空，请输入条码信息','warning');
		}else if(barcode != null && !isValidBarcode(barcode)){
			 $.messager.alert('提示','输入的条码不合法,请重新输入','warning');
		}else{
			dataGrid.datagrid('load', $.serializeObject($('#inventorySearchForm')));
		}		
	}
	
	function downloadStockHistory(){		
		document.inventorySearchForm.action="headqInventoryFlowJSPAction!downloadStockHistory";
		document.inventorySearchForm.submit();
	}
	
	function cleanSearch(){
		$('#barcode').textbox('setValue',null);
	}

</script>
</head>
<body>
<div class="easyui-layout" data-options="fit : true,border : false">
	<div data-options="region:'north',border:false" style="height: 95px;">
	<s:form id="inventorySearchForm" name="inventorySearchForm"
		theme="simple" method="POST">
		<table width="98%" align="center" class="OuterTable">
			<tr>
				<td>
					<table width="100%" border="0">
						<tr>
							<td height="50" colspan="7">
								<div class="errorAndmes">
									<s:actionerror cssStyle="color:red" />
									<s:actionmessage cssStyle="color:blue" />
								</div>
								<table width="100%" border="0">
									<tr class="PBAOuterTableTitale">
										<td height="35" colspan="6">商品库存跟踪记录
										</td>
									</tr>
									

									<tr height="30">
											<td width="5%" height="19" align="center"><strong>单据时间：</strong></td>
											<td width="20%"><s:textfield id="startDate"
														name="formBean.startDate"
														cssClass="easyui-datebox"
														data-options="width:100,editable:false" /> &nbsp;至 &nbsp;
													<s:textfield id="endDate" name="formBean.endDate"
														cssClass="easyui-datebox"
														data-options="width:100,editable:false" /></td>
											<th width="7%" align="center">库房名称：</th>
											<td width="10%" align="left"><s:select cssClass="easyui-combobox" style="width:160px" name="formBean.storeId" data-options="prompt:'请选择库房!'" listKey="id" listValue="name"  id="store" list="uiBean.stores" ></s:select></td>																								
											<td><%@ include
												file="../common/ProductInput.jsp"%></td>
										</tr> 
										
								
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		</s:form>
	</div>
	<div data-options="region:'center',border:false"   >
			<table id="dataGrid" border="0">
			</table>
			<div id="toolbar" style="display: none;">
				<a onclick="searchHqInventotyStock()" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">搜索记录</a>
				<a onclick="downloadStockHistory()" class="easyui-linkbutton" data-options="iconCls:'icon-print',plain:true">下载记录</a>
			</div>
		</div>
</div>

</body>

</html>